package com.albaba.designpattern.memento.text_001;

/**
 * @Description: TODO
 * @Author zx
 * @Date 2025/2/27 15:34
 * @Version 1.0
 */
public class Client {

    public static void main(String[] args) {
        // 创建发起人对象
        Originator o1 = new Originator();
        o1.setId("001");
        o1.setName("张三");
        o1.setPhone("123456789");
        System.out.println("=======" + o1);
        // 创建负责人对象
        Caretaker c1 = new Caretaker();
        c1.setMemento(o1.createMemento());
        System.out.println("=======" + c1);

        // 修改
        o1.setName("李四");
        System.out.println("=======" + o1);

        // 从负责人对象中获取备忘录对象，实现恢复操作
        o1.restoreMemento(c1.getMemento());
        System.out.println("=======" + o1);
    }

}
